import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

plt.rcParams['font.sans-serif'] = 'SimHei'  # 设置中文显示

plt.rcParams['axes.unicode_minus'] = False
hr = pd.read_csv('../Data/hr.csv',encoding='gbk')
data =hr.head(100)

print(type(data))
print(data.head(100))
color_map=dict(zip(data['薪资'].unique(), ['b', 'g', 'r']))
for species,group in data.groupby('薪资'):
    plt.scatter(group['每月平均工作小时数（小时）'],group['满意度'],
                color=color_map[species], alpha=1,
                edgecolors=None, label=species)

plt.legend(frameon=True,title='薪资')

plt.xlabel('平均每月工作时长')
plt.ylabel('满意度水平')
plt.title('满意度水平与平均满意度水平')
plt.show()